package com.tigercel.xiangchengyun.adapter

import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.tigercel.xiangchengyun.R
import com.tigercel.xiangchengyun.entity.ServiceBean


class ServiceAdapter(private val services: List<ServiceBean>,
                     private val itemClick: (ServiceBean) -> Unit) :
        RecyclerView.Adapter<ServiceAdapter.ViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder? {
        val view = LayoutInflater.from(parent.context)
                .inflate(R.layout.item_service, parent, false)
        return ViewHolder(view, itemClick)
    }

    override fun getItemCount(): Int = services.size

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        holder.bindServices(services[position])

    }

    class ViewHolder(view: View, private val itemClick: (ServiceBean) -> Unit) :
            RecyclerView.ViewHolder(view) {
        fun bindServices(ServiceBean: ServiceBean) {
            with(ServiceBean) {
                //                itemView.title.text = title
//                itemView.subTitle.text = subTitle
//                itemView.setOnClickListener { itemClick(this)
//                }
            }
        }

    }

}